import HomeView from '@/views/HomeView.vue'
import NotFindView from '@/views/NotFindView.vue'
import SearchView from '@/views/SearchView.vue'
import {createRouter, createWebHashHistory} from 'vue-router'

// 创建路由实例
const router = createRouter({
  history: createWebHashHistory(),// hash 路由模式 地址栏右 #/ 标识
  routes: [
    {path:'/find',component:()=>import('@/views/FindView.vue')},
    {path:'/my',component:()=>import('@/views/MyView.vue')},
    {path:'/friend',component:()=>import('@/views/FriendView.vue')},
    // redirect 重定向，避免首页白屏
    {path:'/',redirect:'/home'},
    {path:'/home',component:HomeView},
    // 可选动态路由参数，避免没有参数时白屏
    {path:'/search/:keyword?',component:SearchView},
    // 404页面，路径不存在时，避免白屏
    {path:'/:pathMatch(.*)',component:NotFindView}
  ] // 路由表
})

export default router